package tech.aistar.day07;

import java.util.Date;

/**
 * 本类用来演示: 字符串常用的方法
 *
 * @author: success
 * @date: 2022/7/26 2:28 下午
 */
public class StringMethodDemo {
    public static void main(String[] args) {
        System.out.println(String.format("%tF",new Date()));

        //1. 正则表达式来匹配
        //String regex = "[a-z]{3}";
        //注册用户 - 首字母必须是小写.其余单词由\w组成,总共长度6位

        //手机号/邮箱
        String regex = "[a-z]\\w{5}";
        String content = "a123_F";
        System.out.println(content.matches(regex));

        //2. 字符串的截取
        System.out.println("java".substring(1,3));//[start,end)

        //3. 切割
        //String str = "192.168.2.22";
        //String[] arr = str.split("\\.");

        //String str = "192  168 2 22";
        //String[] arr = str.split("\\s+");
        String str = "mysql192java168python2uuu22";
        String[] arr = str.split("[a-zA-Z]+");
        for (String s : arr) {
            System.out.println(s);
        }

        String str2 = "   python     ";
        System.out.println(str2.trim().length());

        String str3 = "   mys ql jav a ";
        System.out.println(str3.replaceAll("\\s+",""));


    }
}
